<?php
class ClaycodeLogin
{
	private static $o_instance;
	private $s_loginKey;
	
	private function __construct()
	{
		$this->s_loginKey = fw_util_encrypt($_SERVER['HTTP_USER_AGENT'] . 'claycode-user-login');
	}
	
	public static function get()
	{
		if(!isset(self::$o_instance) ||  self::$o_instance == null){
			self::$o_instance = new ClaycodeLogin();
		}
		return self::$o_instance;
	}
	
	public function doLogin($o_loginCredentials)
	{
		$_SESSION[$this->s_loginKey] = $o_loginCredentials;	
	}
	
	public function doLogout()
	{
		SessionHandler::getInstance()->destroy();
	}
	
	public function getCredentials()
	{
		return $_SESSION[$this->s_loginKey];
	}
	
	public function isLogged()
	{
		if(isset($_SESSION[$this->s_loginKey])){
			return true;
		}else{
			return false;
		}
	}
	
}